package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ReflectDemo3 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {

        Person p = new Person("严帅",22);
        System.out.println(p);

        Class cls = Class.forName("reflect.Person");

        Constructor c = cls.getConstructor(String.class,int.class);

        Object o = c.newInstance("吴彦祖",45);
        System.out.println(o);

    }
}
